// 验证码
let BackUrl = "http://localhost:10000/wx/c";
function flushCode(i) {
    $(i).attr("src", BackUrl + "/code/checkCode?date=" + new Date())// jQuery获取图片
}
// 登录
function login() {
    let data = {
        userCode:$("#userCode").val(),
        password:$("#password").val(),
        code:$("#code").val()
    }
    let result = myJson("/u/login/login", data);
    console.log(result);
    if (result.message == "该用户的角色已被禁用") {
        alert("该用户的角色已被禁用")
        $("#codeImage").attr("src", BackUrl + "/code/checkCode?date=" + new Date());
    } else if (result.message == "验证码错误或失效") {
        alert("验证码错误或失效")
        $("#codeImage").attr("src", BackUrl + "/code/checkCode?date=" + new Date());
    } else if (result.message == "该用户已被冻结"){
        alert("该用户已被冻结")
        $("#codeImage").attr("src", BackUrl + "/code/checkCode?date=" + new Date());
    } else if (result.message == "密码输入错误超过三次，该用户已被冻结"){
        alert("密码输入错误超过三次，该用户已被冻结")
        $("#codeImage").attr("src", BackUrl + "/code/checkCode?date=" + new Date());
    } else if (result.message == "用户名或密码错误"){
        alert("用户名或密码错误")
        $("#codeImage").attr("src", BackUrl + "/code/checkCode?date=" + new Date());
    }
    else{
        sessionStorage.setItem("token", result.data.tokenHead + result.data.token);
        sessionStorage.setItem("userCode",$("#userCode").val());
        window.location.href = "/html/manage.html";
    }
}


